<?php
namespace models;

use Doctrine\Common\Collections\ArrayCollection;

/**
 * @Entity
 */
class Agen extends Akun{

	/**
	 * @OneToMany(targetEntity="Speedy", mappedBy="agen")
	 */
	protected $speedy;

	/**
	 * @OneToMany(targetEntity="Customer", mappedBy="agen")
	 */
	protected $customer;

    public function __construct($username=null,$password=null,$email=null, $nama=null){
		parent::__construct($username, $password, $email, $nama);
		$this->speedy = new ArrayCollection();
		$this->customer = new ArrayCollection();
	}

	public function add_customer(Customer $customer){
		$this->customer[] = $customer;
	}

	public function get_customer(){
		return $this->customer;
	}

	public function add_speedy(Speedy $speedy){
		$this->speedy[] = $speedy;
	}

	public function get_speedy(){
		return $this->speedy;
	}

	static public function get_dropdown_options(){

		$CI =& get_instance();

		$agen = $CI->doctrine->em
			->createQuery('SELECT a FROM models\Agen a')
			->getResult();

		foreach($agen as $a){
			$option_agen[$a->get_id()] = $a->get_username().' - '.$a->get_nama();
		};

		return $option_agen;
	}
}
